home *** CD-ROM | disk | FTP | other *** search
- /*
-
- F W I N C O E R C I O N O S A X
-
- Version 1.0
- Freeware by Daniel Ranson
-
- This osax performs coercions to the FinderWindow (fwin) record
- type used by Finder events.
-
- There are actually three osax. This one converts aliases.
-
- */
-
- #include <Types.h>
- #include <Memory.h>
- #include <Aliases.h>
- #include <AppleEvents.h>
- #include <AERegistry.h>
-
- struct FinderWindow{
- long windowType;
- DescType aliasType;
- long aliasLength;
- AliasRecord alias;
- };
-
- typedef struct FinderWindow FinderWindow;
-
- pascal OSErr ALIS2FWIN( DescType fromType,
- Ptr dataPtr,
- Size dataSize,
- DescType toType,
- long refCon,
- AEDesc *result)
- {
- #pragma unused(fromType, toType, refCon)
-
- FinderWindow **hFwin;
- Size sizH;
- OSErr err;
-
- /* Allocate the structure */
- sizH = sizeof(FinderWindow) + dataSize - sizeof(AliasRecord);
- hFwin = (FinderWindow**)NewHandle(sizH);
- if (hFwin == 0) return errAECoercionFail;
-
- /* Fill in fields */
- (**hFwin).windowType = 0;
- (**hFwin).aliasType = typeAlias;
- (**hFwin).aliasLength = dataSize;
- BlockMove(dataPtr, &((**hFwin).alias), dataSize);
-
- /* Create the descriptor */
- MoveHHi((Handle)hFwin);
- HLock((Handle)hFwin);
- err = AECreateDesc(typeFinderWindow, (Ptr)(*hFwin), sizH, result);
-
- /* Clean up */
- DisposeHandle((Handle)hFwin);
- return err;
- }
-